package expression;

/**
 * 算式抽象类 - 实验内容2
 * 对算式类进行抽象，设计父类和子类的继承关系
 */
public abstract class Expression {
    protected int left;
    protected int right;
    
    public Expression(int left, int right) {
        this.left = left;
        this.right = right;
    }
    
    public abstract int calculate();
    public abstract String getOperator();
    
    public String getExpression() {
        return left + " " + getOperator() + " " + right + " = ";
    }
    
    public String toString() {
        return getExpression() + calculate();
    }
    
    public int getLeft() { return left; }
    public int getRight() { return right; }
}